package com.example.restful.mapper;

import com.example.restful.model.Student;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface StudentRepository {

    @Select("SELECT * FROM student")
    List<Student> findAll();

    @Select("SELECT * FROM student WHERE id = #{id}")
    Student findById(int id);

    @Insert("INSERT INTO student(student_id, name, className, telephone, qq) VALUES (#{studentId}, #{name}, #{className}, #{telephone}, #{qq})")
    int insert(Student student);

    @Update("UPDATE student SET student_id = #{studentId}, name = #{name}, className = #{className}, telephone = #{telephone}, qq = #{qq} WHERE id = #{id}")
    int update(Student student);

    @Delete("DELETE FROM student WHERE id = #{id}")
    int delete(int id);
}
